﻿using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json.Serialization;
using Hammock;

namespace WWB.DisqusSharp.Infrastructure.HammockWrappers
{
    /// <summary>
    /// Resolves all property names to JSON conventional standard,
    /// i.e. JSON name "this_is_a_property" will map to the class property ThisIsAProperty.
    /// </summary>
    //public class JsonConventionResolver : DefaultContractResolver
    //{
    //    protected override IList<JsonProperty> CreateProperties(JsonObjectContract contract)
    //    {
    //        var properties = base.CreateProperties(contract);

    //        foreach (var property in properties)
    //        {
    //            property.PropertyName = PascalCaseToElement(property.PropertyName);
    //        }

    //        return properties;
    //    }

    //    private static string PascalCaseToElement(string input)
    //    {
    //        if (string.IsNullOrEmpty(input))
    //        {
    //            return null;
    //        }

    //        var result = new StringBuilder();

    //        result.Append(char.ToLowerInvariant(input[0]));
    //        for (var i = 1; i < input.Length; i++)
    //        {
    //            if (char.IsLower(input[i]))
    //            {
    //                result.Append(input[i]);
    //            }
    //            else
    //            {
    //                result.Append("_");
    //                result.Append(char.ToLowerInvariant(input[i]));
    //            }
    //        }

    //        return result.ToString();
    //    }
    //}
}